#ifndef CMD_HISTORY_H
#define CMD_HISTORY_H

#include <string>
#include <deque>

namespace vpm 
{
	namespace cmo
	{
		class CmdHistory 
		{
		public:
			enum 
			{
				MAX_HISTORY_CMDS = 100,
			};

			CmdHistory()
			{
				m_pageIndex =0;
			}

			//add new cmd 
			void add_command(const std::string & cmd)
			{
				m_pageIndex = 0; 
				m_historyCmds.push_front(cmd);
				if (m_historyCmds.size() > MAX_HISTORY_CMDS)
				{
					m_historyCmds.pop_back();
				}				
			}

			//page up 
			std::string page_up() 
			{		
				if (!m_historyCmds.empty() && m_historyCmds.size()> m_pageIndex)
				{
					return m_historyCmds[m_pageIndex++];		
				}
				else 
				{
					return std::string(); 
				}
			}

			//page down 
			std::string page_down()
			{
				if (m_pageIndex >1)
				{
					return m_historyCmds[--m_pageIndex];
				}
				return std::string(); 
			}

		private:
			std::deque<std::string>  m_historyCmds; 			
			unsigned int  m_pageIndex; 					
		};
	}
}



#endif // 
